package com.jx.db137.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jx.db137.common.R;
import com.jx.db137.entity.Menu;
import com.jx.db137.entity.Rolemenu;
import com.jx.db137.service.RolemenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author jx
 * @version 1.0
 * @Description
 * @date 2024/12/24 11:51
 */
@CrossOrigin(origins = "*")
@RestController
public class RolemenuController {
    @Autowired
    private RolemenuService rolemenuService;
    @GetMapping("/selectRoleMenuByRoleId/{roleid}")
    public R selectRoleMenuByRoleId(@PathVariable("roleid") int roleid){
        QueryWrapper<Rolemenu> rolemenuQueryWrapper = new QueryWrapper<>();
        rolemenuQueryWrapper.eq("roleid",roleid);
        List<Rolemenu> roleMenuList = this.rolemenuService.list(rolemenuQueryWrapper);
        return new R().addData("roleMenuList",roleMenuList);
    }


    @PostMapping("/updateRoleMenuId")
    public R updateRoleMenuId(@RequestBody Map<String,Object> map){
        int roleid=Integer.parseInt(map.get("roleid")+"");//角色id
        List<Integer> listMenu =(List<Integer>) map.get("listMenu");
        boolean boo= this.rolemenuService.updateRoleMenuId(roleid,listMenu);

        return new R().addData("boo",boo);
    }








}
